<?php
/**
 * This file is part of PHPlaza (http://code.google.com/p/phplaza)
 * This file is licensed under the GNU Lesser General Public License
 *      http://www.gnu.org/licenses/lgpl.html
 *
 * No warranty is given, express or implied. Use at your own risk.
 */

namespace core::services;

class ServiceRegistrator
{
	private static $instance;
	
	private $services;
	
	const URLSERVICE = 'urlservice';
	const RENDERSERVICE = 'renderservice';
	const STATESERVICE = 'stateservice';
	
	protected function __construct()
	{
		// TODO: read configuration
		
		$this->services = new core::collections::CList();
		$this->services[self::URLSERVICE] = new core::services::urlservice::SimpleURLService();
		$this->services[self::RENDERSERVICE] = new core::services::render::HTMLRenderService();
		$this->services[self::STATESERVICE] = new core::services::stateservice::SessionStateService();
	}
	
	public static function getInstance()
	{
		if (self::$instance == null)
		{
			self::$instance = new ServiceRegistrator();
		}
		
		return self::$instance;
	}
	
	public function getURLService()
	{
		return $this->services[self::URLSERVICE];
	}
	
	public function getRenderService()
	{
		return $this->services[self::RENDERSERVICE];
	}
	
	public function getStateService()
	{
		return $this->services[self::STATESERVICE];
	}
}